/**
 * @author: htqw
 * @description: check config
 */

/**
 * @typedef {Object} Config
 * @property {string} host
 * @property {string} database
 * @property {number} [port]
 * @property {string} [user]
 * @property {string} [password]
 */
/**
 * @param {Config} config
 */
export default function checkConfig(config) {
    if (!config.host) throw new Error('host is required')
    if (!config.database) throw new Error('database is required')
    if (typeof config.host !== 'string') throw new Error('host must be a string')
    if (typeof config.database !== 'string') throw new Error('database must be a string')
    if (config.port && typeof config.port !== 'number') throw new Error('port must be a number')
    if (config.user && typeof config.user !== 'string') throw new Error('user must be a string')
    if (config.password && typeof config.password !== 'string') throw new Error('password must be a string')
}